package com.qk.management.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qk.domain.business.BusinessCountDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qk.common.PageResult;
import com.qk.dto.business.BusinessPageDTO;
import com.qk.dto.business.BusinessPoolPageDTO;
import com.qk.entity.Business;
import com.qk.vo.business.BusinessPageVO;
import com.qk.vo.business.BusinessPoolPageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 *
 * @author MrZhao
 * @created 2025-10-15 10:48
 * @description 商机Mapper
 *
 */
@Mapper
public interface BusinessMapper extends BaseMapper<Business> {
    BusinessCountDO selectCountBusiness();
    Page<BusinessPageVO> selectBusinessPageList(Page<Object> objectPage, BusinessPageDTO dto);

    void updateBackToPool(Business build);

    Page<BusinessPoolPageVO> selectBusinessPoolPageList(Page<Object> objectPage, BusinessPoolPageDTO dto);


   @Update("<script>" +
        "UPDATE business SET user_id = NULL, status = #{status}, update_time = #{updateTime} " +
        "WHERE id IN " +
        "<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
        "#{id}" +
        "</foreach>" +
        "</script>")
void updateByUserIds(@Param("ids") List<Integer> ids,
                         @Param("updateTime") LocalDateTime updateTime,
                         @Param("status") Integer status);


}